//
//  MyButton.swift
//  UIButtonDemo
//
//  Created by itshizhan on 2020/10/12.
//  Copyright © 2020 itshizhan. All rights reserved.
//

import UIKit

class MyButton: UIButton {
	
	override init(frame: CGRect) {
		super.init(frame:frame)
		setImage(UIImage(named: "practice"), for:.normal)
		setTitleColor(UIColor.black, for: .normal)
		contentHorizontalAlignment = .center
		// fillCode
		backgroundColor = UIColor(red: 0.13, green: 0.81, blue: 0.69, alpha: 1)
		layer.cornerRadius = 30
		titleLabel?.font = UIFont.systemFont(ofSize: 20)
		setTitleColor(UIColor.white, for: .normal)

		
	}
	
	//根据Xcode的提示：重写控件的init(frame方法)或者init()方法.必须重写 init?(coder NSCoder)
	required init?(coder: NSCoder) {
		fatalError("init(coder:) has not been implemented")
	}
	
	override func layoutSubviews() {
		super.layoutSubviews()
		 imageView!.frame.origin.x = 40
	}
	
}
